function formIsValid() {
	window.form_errs = [];
	var email_regex = /^[^@]+@[^@]+\.[^@]+$/;
	
	if(!$.trim($('input[name=name]').val())) window.form_errs.push('Name is required.');
	if($.trim($('input[name=email]').val())) {
		if(!email_regex.test($('input[name=email]').val())) window.form_errs.push('Email is invalid.');
	} else window.form_errs.push('Email is required.');
	if(!$.trim($('textarea[name=msg]').val())) window.form_errs.push('Your Message is required');
	
	if(window.form_errs.length) return false;
	else return true;
}

$(document).ready(function() {
	$('#contact_f').submit(function() {
		if(formIsValid()) return true;
		else {
			var err_msg = 'Error(s): \n\n';
			for(var i in window.form_errs) {
				var j = 1 + parseInt(i);
				err_msg += j + '. ' + window.form_errs[i] + '\n';
			}
			alert(err_msg);
			return false;
		}
	});
});